namespace GameSchool.Migrations
{
    using System.Data.Entity.Migrations;
    
    public partial class doddi : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "TeacherCourses",
                c => new
                    {
                        teacherID = c.Int(nullable: false),
                        courseID = c.Int(nullable: false),
                        teacher_teacherID = c.Int(),
                        course_courseID = c.Int(),
                    })
                .PrimaryKey(t => new { t.teacherID, t.courseID })
                .ForeignKey("Teachers", t => t.teacher_teacherID)
                .ForeignKey("Courses", t => t.course_courseID)
                .ForeignKey("Courses", t => t.courseID, cascadeDelete: true)
                .ForeignKey("Teachers", t => t.teacherID, cascadeDelete: true)
                .Index(t => t.teacher_teacherID)
                .Index(t => t.course_courseID)
                .Index(t => t.courseID)
                .Index(t => t.teacherID);
            
            AddColumn("Teachers", "userName", c => c.String());
            AddColumn("Students", "userName", c => c.String());
            AddColumn("Students", "userNameID", c => c.Guid(nullable: false));
        }
        
        public override void Down()
        {
            DropIndex("TeacherCourses", new[] { "teacherID" });
            DropIndex("TeacherCourses", new[] { "courseID" });
            DropIndex("TeacherCourses", new[] { "course_courseID" });
            DropIndex("TeacherCourses", new[] { "teacher_teacherID" });
            DropForeignKey("TeacherCourses", "teacherID", "Teachers");
            DropForeignKey("TeacherCourses", "courseID", "Courses");
            DropForeignKey("TeacherCourses", "course_courseID", "Courses");
            DropForeignKey("TeacherCourses", "teacher_teacherID", "Teachers");
            DropColumn("Students", "userNameID");
            DropColumn("Students", "userName");
            DropColumn("Teachers", "userName");
            DropTable("TeacherCourses");
        }
    }
}
